import {InjectionKey} from 'vue'
import {createStore, useStore as baseUseStore, Store} from 'vuex'
import {menuStore} from '@/store/menu/menuStore'
import {userStore} from "@/store/user/userStore";

export interface State {
    menulist: Array<Object>
    iconObj: Object
    isCollapse: Boolean
    activePath: String
    userListInfo: object
    total: number
}

export const key: InjectionKey<Store<State>> = Symbol()

export const store = createStore<State>({
    // state: {
    //     menulist: [],
    //     iconObj: {
    //         125: 'iconfont icon-location',
    //         103: 'iconfont icon-menu',
    //         101: 'iconfont icon-text',
    //         102: 'iconfont icon-yonghu',
    //         145: 'iconfont icon-setting'
    //     },
    //     isCollapse: false,
    //     activePath: '',
    //     userListInfo: {
    //         'query': '',
    //         'pagenum': 1,
    //         'pagesize': 2,
    //     },
    //     total: 0
    // },
    // getters: {
    //     getMenuList: (state: State) => {
    //         return state.menulist
    //     },
    //     getIconObj: (state: State) => {
    //         return state.iconObj
    //     },
    //     getCollapse: (state: State) => {
    //         return state.isCollapse
    //     },
    //     getActivaPath: (state: State) => {
    //         return state.activePath
    //     },
    //     getUserListInfo: (state: State) => {
    //         return state.userListInfo
    //     },
    //     getTotal: (state: State) => {
    //         return state.total
    //     }
    // },
    // mutations: {
    //     setMenuList: (state: State, payload) => {
    //         // console.log(payload)
    //         state.menulist = payload
    //     },
    //     setCollapse: (state: State, payload) => {
    //         state.isCollapse = payload
    //     },
    //     setActivePath: (state: State, payload) => {
    //         state.activePath = payload
    //     },
    //     setTotal: (state: State, payload) => {
    //         state.total = payload
    //     },
    // }
    modules:{
        menuStore,
        userStore,
    }
})

// define your own `useStore` composition function
export function useStore() {
    return baseUseStore(key)
}
